home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14117 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.0 KB  |  69 lines

  1. Path: sed.psrw.com!psinntp!psinntp!psinntp!pipeline!not-for-mail
  2. From: johndill@nyc.pipeline.com (John Dillworth)
  3. Newsgroups: comp.lang.c
  4. Subject: Why does this trip over control codes (Win 3.1 SDK)
  5. Date: 11 Apr 1996 15:49:34 -0400
  6. Organization: Pipeline
  7. Message-ID: <4kjnoe$di2@pipe10.nyc.pipeline.com>
  8. NNTP-Posting-Host: pipe10.nyc.pipeline.com
  9. X-PipeUser: johndill
  10. X-PipeHub: nyc.pipeline.com
  11. X-PipeGCOS: (John Dillworth)
  12. X-Newsreader: Pipeline v3.5.0
  13.  
  14. I'm trying to modify the poepoem.c program from Petzold to print source
  15. code instead of just text.  The .rc file looks like this 
  16.  
  17. /*---------------------------- 
  18.    POEPOEM.RC resource script 
  19.   ----------------------------*/ 
  20.  
  21. #include "poepoem.h" 
  22.  
  23. poepoem     ICON  poepoem.ico 
  24. AnnabelLee  TEXT  poepoem.asc 
  25.  
  26. STRINGTABLE 
  27.      { 
  28.      IDS_APPNAME, "poepoem" 
  29.      IDS_CAPTION, """Annabel Lee"" by Edgar Allen Poe" 
  30.      IDS_POEMRES, "AnnabelLee" 
  31.  
  32. The AnnabelLee  TEXT  poepoem.asc line points to an text file.  It prints
  33. just fine.  If I want the program to print source code it has a problem
  34. with the C control characters and stops printing when it hits one.  The
  35. fragment from the >c file is  
  36.  
  37. LoadString (hInst, IDS_POEMRES, szPoemRes, sizeof szPoemRes) ; 
  38.                hResource = LoadResource (hInst,  
  39.                            FindResource (hInst, szPoemRes, "TEXT")) ; 
  40.  
  41.                lpText = LockResource (hResource) ; 
  42.  
  43.                nNumLines = 0 ; 
  44.  
  45.                while (*lpText != '\\' && *lpText != '\0') 
  46.                     { 
  47.                     if (*lpText == '\n') 
  48.                          nNumLines ++ ; 
  49.                     lpText = AnsiNext (lpText) ; 
  50.                     } 
  51.                *lpText = '\0' ; 
  52.  
  53.                GlobalUnlock (hResource) ; 
  54.  
  55.                SetScrollRange (hScroll, SB_CTL, 0, nNumLines, FALSE) ; 
  56.                SetScrollPos   (hScroll, SB_CTL, 0, FALSE) ; 
  57.                return 0 ; 
  58.  
  59.  
  60. How can I make this program print source code? 
  61.  
  62.  
  63. Thanks 
  64.  
  65.      } 
  66. -- 
  67.  
  68. John Dillworth
  69.